package com.dd.common.dto.system.user;

import com.dd.common.utils.StrGenerator;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.io.Serializable;

@Schema(description = "创建系统用户DTO")
@Data
public class SysUserCreateDTO implements Serializable {

    @NotBlank(message = "密码不能为空")
    @Size(min = 6, max = 128, message = "密码长度必须在6到128位之间")
    @Schema(description = "密码", example = "123456", requiredMode = Schema.RequiredMode.REQUIRED)
    private String password;

    @NotBlank(message = "用户名不能为空")
    @Schema(description = "账号用户名（仅限字母、数字、下划线）", example = "admin_user_1",requiredMode = Schema.RequiredMode.REQUIRED)
    @Pattern(regexp = "^[a-zA-Z0-9_]{4,30}$", message = "用户名必须由4-30位字母、数字或下划线组成")
    private String username;

    @Schema(description = "头像")
    private String avatar = StrGenerator.generateRandomAvatar();
}
